/**
 * @param {number[]} nums
 * @param {number} k
 * @return {number}
 */
 var findKthLargest = function(nums, k) {
    let len = nums.length

    function swap(x,y){
        var temp = nums[x]
        nums[x] = nums[y]
        nums[y] = temp 
    }
   
    switch (method) {
        case 1:  // 冒泡排序
            for(let i=0; i<len-1; i++){
                for(let j=i+1; j<len; j++){
                    if(nums[i] < nums[j]){
                        swap(i, j)
                    }
                }
            }
            break;
        case 2: //  快速排序
        for(let i=1; i<len; i++){
            for(let j=0; j<i; j++){
                if(nums[i] > nums[j]){
                    swap(i,j)
                }
            }
        } 
        break;
        case 3: //二分查询
            var left = 0, right = len -1
            var mid = Math.round((left + right) / 2)
            console.log(mid)
        break;
        default:
            break;
    }

    
    console.log(nums)
    // 选择排序
    // 
};

var method = 2
findKthLargest([3,2,1,5,6,4], 2)